package logic

import (
	"api/model/mysql"
	"context"

	"goods_srv/goods"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
	return &ListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListLogic) List(in *goods.ListRequest) (*goods.ListResponse, error) {
	// todo: add your logic here and delete this line

	var list mysql.Goods
	mysql.DB.Find(&list)

	return &goods.ListResponse{
		Id:          int64(list.ID),
		GoodsImg:    list.GoodsImg,
		GoodsName:   list.GoodsName,
		GoodsNum:    int64(list.GoodsNum),
		GoodsPrice:  float32(list.GoodsPrice),
		GoodsStatus: int64(list.GoodsStatus),
	}, nil
}
